--Stargate Gamemode--

--Here you can change the password for example change it to SetAlteranPassword = "Earth"

SetAlteranPassword = "Alteran"

/*

	The following lines are the code for the client. Please don't change them unless you
	want to make your own gamemode.
  
	Thanks.
  
*/





include( 'shared.lua' )

////////////////////
////////VGUI////////
////////////////////

--Box for choosing the team--
local BackGround = vgui.Create("DFrame")
local ply = LocalPlayer()
BackGround:SetPos((ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall())
BackGround:SetSize(200,200)
BackGround:SetTitle("Choose Team")
BackGround:Center()
BackGround:SetDraggable(false)
BackGround:ShowCloseButton(false)
BackGround:SetVisible(true)
BackGround:MakePopup()
	
local Button1 = vgui.Create("DButton", BackGround)
Button1:SetPos(50,30)
Button1:SetSize(100,50)
Button1:SetText("Tau'ri")

local Button2 = vgui.Create("DButton", BackGround)
Button2:SetPos(50,85)
Button2:SetSize(100,50)
Button2:SetText("Goa'uld")

function BackGround:Think()
    local xy = BackGround:GetSize()
    if xy != {200,200} then
            BackGround:SetSize( 200, 200 )
        end
		
    Button1:SetPos(50,30)
	Button2:SetPos(50,85)	
	
end

function Button1:DoClick(ply)
    LocalPlayer():ConCommand("sg_tauri\n")
	BackGround:SetVisible(false)
	
end

function Button2:DoClick(ply)
    LocalPlayer():ConCommand("sg_goauld\n")
	BackGround:SetVisible(false)
	
end

--Box for asking the player whether he wants to change the team--
local BackGround2 = vgui.Create("DFrame")
BackGround2:SetPos((ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall())
BackGround2:SetSize(200,135)
BackGround2:SetTitle("You want to change the team?")
BackGround2:Center()
BackGround2:SetDraggable(false)
BackGround2:ShowCloseButton(false)
BackGround2:SetVisible(false)
BackGround2:MakePopup()
	
local Button3 = vgui.Create("DButton", BackGround2)
Button3:SetPos(50,30)
Button3:SetSize(100,50)
Button3:SetText("Yes")

local Button4 = vgui.Create("DButton", BackGround2)
Button4:SetPos(50,85)
Button4:SetSize(100,50)
Button4:SetText("No")

function BackGround2:Think()
    local xy = BackGround2:GetSize()
    if xy != {200,200} then
            BackGround2:SetSize( 200, 200 )
        end
		
    Button3:SetPos(50,30)
	Button4:SetPos(50,85)	
	
end

function Button3:DoClick(ply)
    BackGround:SetVisible(true)
	BackGround2:SetVisible(false)
	
end

function Button4:DoClick(ply)
	BackGround2:SetVisible(false)
	
end

--Button-Box--
local BackGround3 = vgui.Create("DFrame")
BackGround3:SetPos(0, ScrH()/2)
BackGround3:SetSize(160,100)
BackGround3:SetTitle("Change Team")
BackGround3:SetDraggable(true)
BackGround3:ShowCloseButton(false)
	
local Button5 = vgui.Create("DButton", BackGround3)
Button5:SetPos(30,30)
Button5:SetSize(100,50)
Button5:SetText("Change Team")

function BackGround3:Think()
    local xy = BackGround3:GetSize()
    if xy != {160,100} then
            BackGround2:SetSize( 160, 100 )
        end
		
    Button5:SetPos(30,30)	
	
end

function Button5:DoClick(ply)
    BackGround2:SetVisible(true)
	
end

function VGUI()
	BackGround2:SetVisible(true)

end

--Alteran/Admin Password Menu
local AlteranPasswordMenu = vgui.Create("DFrame")
AlteranPasswordMenu:SetPos((ScrW()/2)-AlteranPasswordMenu:GetWide(),(ScrH()/2)-AlteranPasswordMenu:GetTall())
AlteranPasswordMenu:SetSize(200,140)
AlteranPasswordMenu:SetTitle("Type in the password")
AlteranPasswordMenu:Center()
AlteranPasswordMenu:SetDraggable(false)
AlteranPasswordMenu:ShowCloseButton(false)
AlteranPasswordMenu:SetVisible(false)
AlteranPasswordMenu:MakePopup()

local WrongPassword = vgui.Create("DLabel", AlteranPasswordMenu)
WrongPassword:SetText("")
WrongPassword:SetPos(20,50)
WrongPassword:SetTextColor(Color(0,0,0,255))
WrongPassword:SizeToContents()

local Button6 = vgui.Create("DButton", BackGround)
Button6:SetPos(50,140)
Button6:SetSize(100,50)
Button6:SetText("Alteran")

local BackButton = vgui.Create("DButton", AlteranPasswordMenu)
BackButton:SetPos(50,80)
BackButton:SetSize(100,50)
BackButton:SetText("Back")

function BackButton:DoClick(ply)
    BackGround:SetVisible(true)
	AlteranPasswordMenu:SetVisible(false)
	
end

local AlteranPassword = vgui.Create("DTextEntry", AlteranPasswordMenu)
AlteranPassword:SetPos(20,30)
AlteranPassword:SetTall(20)
AlteranPassword:SetWide(160)
AlteranPassword:SetEnterAllowed(true)
AlteranPassword.OnEnter = function()
	if(AlteranPassword:GetValue() == SetAlteranPassword) then
		LocalPlayer():ConCommand("sg_alteran\n")
		AlteranPasswordMenu:SetVisible(false)
		WrongPassword:SetText("")
		WrongPassword:SetPos(20,50)
		WrongPassword:SetTextColor(Color(0,0,0,255))
		WrongPassword:SizeToContents()
	else
		WrongPassword:SetText("Wrong Password")
		WrongPassword:SetPos(20,50)
		WrongPassword:SetTextColor(Color(255,0,0,255))
		WrongPassword:SizeToContents()
	end

end

function Button6:DoClick(ply)
	BackGround:SetVisible(false)
    AlteranPasswordMenu:SetVisible(true)
	
end

/////////////
/////HUD/////
/////////////

function ShouldHudDraw(name)

	for k,v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do
		if name == v then
			return false
		end	
	end

end

hook.Add("HUDShouldDraw", "HideHUD", ShouldHudDraw)


function GM:HUDPaint()

self.BaseClass:HUDPaint()

local ply = LocalPlayer()

if( !ply:Alive()) then
	return
end

local HP = ply:Health()
local Suit = ply:Armor()
local Ammo = ply:GetActiveWeapon():Clip1()
local TotalAmmo = ply:GetAmmoCount(ply:GetActiveWeapon():GetPrimaryAmmoType())

if ply:Team() == 1 then
	
	surface.CreateFont("TargetID", 50, 300, true, false, "TauriFont")
	surface.SetTextColor(255,255,255,255)
	surface.SetFont("TauriFont")

	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)-100)
	surface.DrawText("Status of Player:")
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)-50)
	surface.DrawText("Health: "..HP)
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3))
	surface.DrawText("Suit: "..Suit)
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)+50)
	surface.DrawText("Ammo: "..Ammo.."/"..TotalAmmo)
	
	surface.SetDrawColor(255,255,0,255)
	surface.DrawOutlinedRect((ScrW()/2)-(ScrW()/2.2)-5, (ScrH()/2)+(ScrH()/3)-100,310,200)
	surface.SetDrawColor(255,255,0,130)
	surface.DrawRect((ScrW()/2)-(ScrW()/2.2)-5, (ScrH()/2)+(ScrH()/3)-100,310,200)
	
elseif ply:Team() == 2 then
	
	surface.CreateFont("TargetID", 50, 300, true, false, "GoauldFont")
	surface.SetTextColor(255,255,255,255)
	surface.SetFont("GoauldFont")

	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)-100)
	surface.DrawText("Status of Player:")
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)-50)
	surface.DrawText("Health: "..HP)
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3))
	surface.DrawText("Suit: "..Suit)
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)+50)
	surface.DrawText("Ammo: "..Ammo.."/"..TotalAmmo)
	
	surface.SetDrawColor(255,0,0,255)
	surface.DrawOutlinedRect((ScrW()/2)-(ScrW()/2.2)-5, (ScrH()/2)+(ScrH()/3)-50,310,200)
	surface.SetDrawColor(255,0,0,130)
	surface.DrawRect((ScrW()/2)-(ScrW()/2.2)-5, (ScrH()/2)+(ScrH()/3)-100,310,200)
	
elseif ply:Team() == 3 then
	
	surface.CreateFont("Anquietas", 50, 300, true, false, "AlteranFont")
	surface.SetTextColor(255,255,255,255)
	surface.SetFont("AlteranFont")
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)-100)
	surface.DrawText("Status of Player:")
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)-50)
	surface.DrawText("Health: "..HP)
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3))
	surface.DrawText("Suit: "..Suit)
	
	surface.SetTextPos((ScrW()/2)-(ScrW()/2.2), (ScrH()/2)+(ScrH()/3)+50)
	surface.DrawText("Ammo: "..Ammo.."/"..TotalAmmo)
	
	surface.SetDrawColor(92,102,255,255)
	surface.DrawOutlinedRect((ScrW()/2)-(ScrW()/2.2)-5, (ScrH()/2)+(ScrH()/3)-110,325,210)
	surface.SetDrawColor(92,102,255,130)
	surface.DrawRect((ScrW()/2)-(ScrW()/2.2)-5, (ScrH()/2)+(ScrH()/3)-110,325,210)
	
	end
	
end

concommand.Add("sg_menu", VGUI)